package gat.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * @author sxq
 * @date 2021/12/17
 * <p>
 * 支付单状态,
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum PaymentStatusEnum {

    /**
     * 支付单不涉及业务,只有成功与否
     * 超时未支付也是取消
     */
    WAITING(0, "待支付"),
    CANCEL(1, "已取消"),
    ERROR(2, "支付失败"),
    FINISH(9, "支付完成");

    private Integer code;
    private String desc;

    public static PaymentStatusEnum getByCode(Integer code) {
        for (PaymentStatusEnum paymentStatusEnum : values()) {
            if (paymentStatusEnum.getCode().equals(code)) {
                return paymentStatusEnum;
            }
        }
        return null;
    }

}
